package com.ad.nbi.NotificationIRP;

import java.util.Random;

import org.omg.CORBA.IntHolder;
import org.omg.CORBA.ORB;

import com.ad.nbi.Constants;

import CosNotifyChannelAdmin.SequenceProxyPullSupplier;
import CosNotifyChannelAdmin.SequenceProxyPullSupplierHolder;
import CosNotifyChannelAdmin.SequenceProxyPushSupplierHolder;
import ManagedGenericIRPConstDefs.Method;
import ManagedGenericIRPConstDefs.StringOpt;
import ManagedGenericIRPConstDefs.StringOptHolder;
import ManagedGenericIRPSystem.InvalidParameter;
import ManagedGenericIRPSystem.OperationNotSupported;
import ManagedGenericIRPSystem.ParameterNotSupported;
import NotificationIRPConstDefs.NotificationTypesSetHolder;
import NotificationIRPConstDefs.SubscriptionStateHolder;
import NotificationIRPSystem.AlreadySubscribed;
import NotificationIRPSystem.AtLeastOneNotificationCategoryNotSupported;
import NotificationIRPSystem.Attach;
import NotificationIRPSystem.ChangeSubscriptionFilter;
import NotificationIRPSystem.DetachException;
import NotificationIRPSystem.GetNotificationCategories;
import NotificationIRPSystem.GetNotificationIRPNotificationProfile;
import NotificationIRPSystem.GetNotificationIRPOperationsProfile;
import NotificationIRPSystem.GetNotificationIRPVersions;
import NotificationIRPSystem.GetSubscriptionIds;
import NotificationIRPSystem.GetSubscriptionStatus;

/**
 * This class is the implemetation object for your IDL interface.
 *
 * Let the Eclipse complete operations code by choosing 'Add unimplemented methods'.
 */
public class NotificationIRPServerImpl extends NotificationIRPSystem.NotificationIRPPOA {
	/**
	 * Constructor for NotificationIRPServerImpl 
	 */
	private ORB orb;
	public NotificationIRPServerImpl() {
	}

	@Override
	public String[] get_notification_irp_versions()
			throws GetNotificationIRPVersions {
		String[] version = { Constants.VERSION.Notification };
		return version;
	}

	@Override
	public Method[] get_notification_irp_operations_profile(
			String notification_irp_version) throws InvalidParameter,
			OperationNotSupported, GetNotificationIRPOperationsProfile {
		Method[] methods = new Method[] {
				new Method("get_notification_irp_versions",
						new String[] { "" }),
				new Method("get_notification_irp_operations_profile",
						new String[] { "String:notification_irp_version" }),
				new Method("get_notification_irp_notification_profile",
						new String[] { "String:notification_irp_version" }),
				new Method("get_notification_categories", new String[] {"NotificationTypesSetHolder:notification_type_list"})
		};
		return methods;
	}

	@Override
	public Method[] get_notification_irp_notification_profile(
			String notification_irp_version)
			throws GetNotificationIRPNotificationProfile, InvalidParameter,
			OperationNotSupported {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String[] get_notification_categories(
			NotificationTypesSetHolder notification_type_list)
			throws GetNotificationCategories, OperationNotSupported {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String attach_push(String manager_reference, int time_tick,
			String[] notification_categories, StringOpt filter)
			throws AlreadySubscribed, InvalidParameter, Attach,
			AtLeastOneNotificationCategoryNotSupported, ParameterNotSupported {
		
		int val =  1000+(int)Math.random()*100 ;
		return (new Integer(val)).toString();
	}

	@Override
	public String attach_push_b(String manager_reference, int time_tick,
			String[] notification_categories, StringOpt filter,
			SequenceProxyPushSupplierHolder system_reference)
			throws AlreadySubscribed, InvalidParameter, OperationNotSupported,
			Attach, AtLeastOneNotificationCategoryNotSupported,
			ParameterNotSupported {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String attach_pull(String manager_reference, int time_tick,
			String[] notification_categories, StringOpt filter,
			SequenceProxyPullSupplierHolder system_reference)
			throws AlreadySubscribed, InvalidParameter, OperationNotSupported,
			Attach, AtLeastOneNotificationCategoryNotSupported,
			ParameterNotSupported {
		// TODO Auto-generated method stub
		system_reference.value =  null;
		return "1003";
	}

	@Override
	public void change_subscription_filter(String subscription_id, String filter)
			throws InvalidParameter, OperationNotSupported,
			ChangeSubscriptionFilter {
		// TODO Auto-generated method stub
		
	}

	@Override
	public String[] get_subscription_status(String subscription_id,
			StringOptHolder filter_in_effect,
			SubscriptionStateHolder subscription_state, IntHolder time_tick)
			throws InvalidParameter, OperationNotSupported,
			GetSubscriptionStatus {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String[] get_subscription_ids(String manager_reference)
			throws InvalidParameter, OperationNotSupported, GetSubscriptionIds {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void detach(String manager_reference, String subscription_id)
			throws InvalidParameter, DetachException, ParameterNotSupported {
		// TODO Auto-generated method stub
		
	}



	public ORB getOrb() {
		return orb;
	}

	public void setOrb(ORB orb) {
		this.orb = orb;
	}
	
}
